k = int(input())
line = input().split()
s = line[0]
s=" "+s
c1 = line[1]
c2 = line[2]
cnt = 0
c = [0]*len(s)
for i in range(1,len(s)):
    if s[i]==c1 : c[i] += 1
    c[i]+=c[i-1]
    if i>=k and s[i]==c2:
        cnt+=c[i-k+1]
print(cnt)
